home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung / Power-Programmierung (Tewi)(1994).iso / magazine / dbms_mag / 9107 / techtip2 < prev   
Text File  |  1991-05-21  |  3KB  |  76 lines

  1. *****************************************************************
  2. «MDSD»«MDNM»* BANNER()
  3. *
  4. * Displays a moving line of quotes or other information that
  5. * runs until the user presses a key. It then returns the
  6. * INKEY() value of the key to the calling program.
  7. *
  8. *** nRow     = The starting row of the banner.
  9. *** nCol     = The starting column of the banner.
  10. *** cString  = The string (any "practical" length) to be
  11. ***            displayed.
  12. *** nLgth    = The width of the banner window.
  13. *** lBeep    = .T. : Beep as characters are shoved into
  14.                      the stream.
  15.                .F. : No beep.
  16. *
  17. *** The rate of the data stream can be altered by changing
  18. *** the INKEY() value.
  19. *** Written for use with Clipper 5.0. Can be used with other
  20. *** Xbase products if LOCAL declarations are replaced with
  21. *** PRIVATEs and the ":=" operator is replaced with "=."
  22. *****************************************************************
  23.  
  24. *** Sample use follows:
  25. ***********************
  26. cPasStrng:="Common sense is the most widely shared commodity " +;
  27.            "in the world, for every man is convinced that he " +;
  28.            "is well supplied with it. - Descartes ... A great " +;
  29.             part of courage is the courage of having done the " +;
  30.             thing before. - Ralph Waldo Emerson ... "
  31.  
  32. nRetVal := BANNER(24,1,cPasStrg,80)
  33.  
  34. RETURN
  35.  
  36. *****************************************************************
  37. FUNCTION BANNER
  38. *****************************************************************
  39. local cSaystring,keypress
  40. PARAMETERS nRow, nCol, cString, nLgth, lBeep
  41. IF EMPTY(nLgth)
  42.     nLgth:=80
  43. ENDIF
  44. IF EMPTY(nRow)
  45.     nRow:=24
  46. ENDIF
  47. IF EMPTY(lBeep)
  48.     lBeep:=.F.
  49. ENDIF
  50. keypress:=0
  51. DO WHILE .T.               && Display until a key is pressed
  52. FOR i = 1 to len(cString)  && Increment through the entire string
  53. *****Establish the display window
  54.      cSaystring:=IIF(nLgth < (LEN(cString)-i), ;
  55.      SUBSTR(cString,i,nLgth),SUBSTR(cString,i,(len(cString)-i)) + ;
  56.      SUBSTR(cString,1, i-1))
  57. IF ISCOLOR()
  58.      SETCOLOR("N/W+")
  59. ELSE
  60.      SET COLOR TO I                && Reverse out the banner
  61. ENDIF
  62.      @ nRow , nCol SAY cSaystring  && Display the banner
  63.  
  64.      SET COLOR TO                  && Reset the colors
  65.  
  66.      keypress:=INKEY(.08)          && Wait for a keystroke
  67.      IF lBeep
  68.           tone(30,.1)
  69.      ENDIF
  70.      IF keypress # 0
  71.           RETURN keypress          && Return the key pressed
  72.      ENDIF
  73.  
  74. NEXT
  75. ENDDO
  76.